package 面试.新国都;

import java.util.Scanner;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author : K k
 * @date : 20:59 2020/9/22
 * 打印指定尺寸的XGD。
 * 一个整数n，1 <= n <= 5
 * 对应尺寸的XGD
 * 示例1
 * 输入
 * 1
 * 输出
 * XGD
 * 示例2
 * 输入
 * 2
 * 输出
 * X   X GGGGDDD
 *  X X G    D  D
 *   X  G  GGD   D
 *  X X G   GD  D
 * X   X GGGGDDD
 */
public class 打印字母图像 {
    static int[][] help_x = {{0,0},{0,4},{1,1},{1,3},{2,2},{3,1},{3,3},{4,0},{4,4}};
    static int[][] help_g = {{0,1},{0,2},{0,3},{0,4},{1,0},{2,0},{2,3},{2,4},{3,0},{3,4},{4,1},{4,2},{4,3},{4,4}};
    static int[][] help_d = {{0,0},{0,1},{0,2},{1,0},{1,3},{2,0},{2,4},{3,0},{3,3},{4,0},{4,1},{4,2}};
    public static char[][] help(int n,char c){
        char[][] res;//当前数组
        if(n==1) {//递归终止条件
            res = new char[1][1];
            res[0][0] = c;
            return res;
        }
        int length = (int)Math.pow(5,n-2);//下一次递归数组的长度
        int size = length * 5; //本次递归数组的长度
        res = new char[size][size]; //本次递归的数组
        char[][] tmp = help(n-1,c); //下一次递归
        int[][] help;   //辅助数组
        if(c=='X')help=help_x;
        else if(c=='G')help=help_g;
        else help = help_d;
        for(int[] pot : help)   //进行copy
            copy(res,tmp,pot[0] * length,pot[1]*length);
        return res;
    }

    /**
     *
     * @param big 当前打印的数组
     * @param small 上一次打印的数组
     * @param x
     * @param y
     */
    public static  void copy(char[][] big,char[][] small,int x,int y){
        for(int i=0;i<small.length;i++){
            for (int j = 0; j < small[0].length; j++) {
                big[i+x][j+y] = small[i][j];
            }
        }
    }

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        long start = System.currentTimeMillis();
        char[][] res_x =help(n,'X');
        char[][] res_g =help(n,'G');
        char[][] res_d =help(n,'D');
        for (int i = 0;i<res_x.length;i++) {
            System.out.print(res_x[i]);
            System.out.print(res_g[i]);
            int empty=0;//辅助输出空格
            for (char a:res_d[i]) {
                if(a=='D'){
                    for(;empty>0;empty--)System.out.print(" ");
                    System.out.print(a);
                }
                else empty++;
            }
            System.out.println();
        }
        long end=System.currentTimeMillis();
        System.out.println((double)(end-start)/1000);
    }
}
